<template>
  <div class="maintainer">
    <ws-table :columns="tableColumns"
              :operation="operation"
              url="post|/basicParameter/maintainer/listAll"
              @handleDelete="handleDelete"
    >
      <template #unit="{row}">
        {{ row.unit.unitName }}
      </template>
      <template #content="{row}">
        {{ row.userContent.content.fastCodeName }}
      </template>
      <template #vehicleNo="{row}">
        {{ row.userContent.vehicleNo }}
      </template>
      <template #opera="{row, index}">
        <el-button link type="primary" :disabled="row.userContent.content.fastCodeId===1" @click="handleInfo(row, index)">补充资料</el-button>
        <el-button link type="primary" @click="handleArea(row, index)">维护片区</el-button>
        <el-button link type="primary" :disabled="row.userContent.content.fastCodeId===1" @click="handleRest(row, index)">休息排班</el-button>
        <el-button link type="primary" :disabled="row.userContent.content.fastCodeId===1" @click="handleWork(row, index)">工作轨迹</el-button>
      </template>
    </ws-table>
  </div>
</template>

<script setup>
defineOptions({
  name: 'basicParameter_maintainer'
})
const state = reactive({
  tableColumns: [
    { label: '人员编号', prop: 'userId', minWidth: 130 },
    { label: '人员名称', prop: 'userName', minWidth: 130 },
    { label: '维护单位', type: 'slot', prop: 'unit', minWidth: 180 },
    { label: '电话号码', prop: 'telephone', minWidth: 105 },
    { label: '人员职责', type: 'slot', prop: 'content', minWidth: 105 },
    { label: '车牌号码', type: 'slot', prop: 'vehicleNo', minWidth: 105 },
    { label: '小组成员', prop: 'userGroupNames', minWidth: 105 },
    { label: '维护片区', prop: 'areaNames', minWidth: 105 },
    { label: '用户描述', prop: 'userDesc', minWidth: 170 }
  ],
  operation: {
    fixed: 'right',
    data: [{ label: '删除', handle: 'delete', type: 'danger' }],
    width: 364
  }
})
const { tableColumns, operation } = toRefs(state)
const handleDelete = (row) => {
  EmessageBox('确定删除吗？', '删除').then(() => {
    console.log('删除成功！', row)
  }).catch(() => {
    console.log('取消删除')
  })
}
const handleInfo = (row) => {
  console.log('补充信息', row)
}
const handleArea = (row) => {
  console.log('维护片区', row)
}
const handleRest = (row) => {
  console.log('休息排班', row)
}
const handleWork = (row) => {
  console.log('工作轨迹', row)
}
</script>

<style lang="scss" scoped>
.maintainer {
  width: 100%;
  height: 100%;
  position: relative;
}
</style>
